package base

object State{
    private val msgMap = HashMap<String, String>()
    private val errorMap = HashMap<String, String>()

    const val STATE_SUCCESS = "200"
    const val STATE_FAIL = "300"

    const val STATE_USER_REGISTER_FAIL= "401"
    const val STATE_USER_REQUEST_VERIFY_CODE_FAIL = "402"
    const val STATE_USER_LOGIN_FAIL = "403"

    const val STATE_GOODS_PUBLISH_FAIL = "501"

    const val ERROR_UNKNOWN = "300"
    const val ERROR_SERVER_INSIDE_ERROR = "301"
    const val ERROR_REQUEST_PARAS_ERROR = "302"
    const val ERROR_ILLEGAL_PARA = "303"
    const val ERROR_PERMISSION_LACK = "304"

    const val ERROR_USER_INVALID_PHONE = "401"
    const val ERROR_USER_VERIFY_CODE = "402"
    const val ERROR_USER_VERIFY_CODE_EXPIRED = "403"
    const val ERROR_USER_PHONE_HAS_SIGNED = "404"
    const val ERROR_USER_USERNAME_HAS_EXISTED = "405"
    const val ERROR_USER_PHONE_NOT_SIGNED = "406"
    const val ERROR_USER_TOKEN_UNTRUSTWORTHY = "407"
    const val ERROR_USER_TOKEN_EXPIRED = "408"
    const val ERROR_USER_USER_NOT_EXIST = "409"
    const val ERROR_USER_USERNAME_OR_PWD_EMPTY = "410"
    const val ERROR_USER_WRONG_PASSWORD = "411"
    const val ERROR_USER_NOT_LOGIN_PERMISSION = "412"

    const val ERROR_GOODS_AT_LEAST_ONE_PIC = "501"
    const val ERROR_GOODS_NO_MORE_RECORD = "502"
    const val ERROR_GOODS_NO_PUBLISH_PERMISSION = "503"

    const val ERROR_ORDER_UNKNOWN = "601"
    const val ERROR_ORDER_NOT_EXIST = "602"
    const val ERROR_ORDER_NOT_ORDERS = "603"
    const val ERROR_ORDER_GOODS_NOT_EXIST = "604"
    const val ERROR_ORDER_NO_BUY_PERMISSION = "605"

    const val ERROR_RECORD_NOT_ANY_BOUGHT = "701"
    const val ERROR_RECORD_NOT_ANY_COLLECTION = "702"
    const val ERROR_RECORD_NOT_ANY_SOLD = "703"
    const val ERROR_RECORD_NOT_RECORD = "704"

    const val ERROR_RES_UPLOAD_FAIL = "801"

    const val ERROR_COMMENT_COMMENT_FAIL = "901"
    const val ERROR_COMMENT_NO_COMMENT = "902"
    const val ERROR_COMMENT_DELETE_FAIL = "903"
    const val ERROR_COMMENT_NO_PERMISSION = "904"


    init {
        msgMap[STATE_SUCCESS] = "success"
        msgMap[STATE_FAIL] = "fail"
        msgMap[STATE_USER_REGISTER_FAIL] = "注册失败"
        msgMap[STATE_USER_REQUEST_VERIFY_CODE_FAIL] = "获取短信验证码失败"
        msgMap[STATE_USER_LOGIN_FAIL] = "登录失败"
        msgMap[STATE_GOODS_PUBLISH_FAIL] = "发布失败"

        errorMap[ERROR_UNKNOWN] = "未知原因"
        errorMap[ERROR_REQUEST_PARAS_ERROR] = "请求参数错误"
        errorMap[ERROR_ILLEGAL_PARA] = "非法参数"
        errorMap[ERROR_SERVER_INSIDE_ERROR] = "服务器内部错误"
        errorMap[ERROR_PERMISSION_LACK] = "缺少必要权限"

        errorMap[ERROR_USER_INVALID_PHONE] = "无效手机号码"
        errorMap[ERROR_USER_VERIFY_CODE] = "验证码错误"
        errorMap[ERROR_USER_VERIFY_CODE_EXPIRED] = "无效验证码"
        errorMap[ERROR_USER_PHONE_HAS_SIGNED] = "号码已注册"
        errorMap[ERROR_USER_USERNAME_HAS_EXISTED] = "注册失败, 请重试"
        errorMap[ERROR_USER_PHONE_NOT_SIGNED] = "号码未注册"
        errorMap[ERROR_USER_TOKEN_UNTRUSTWORTHY] = "token验证失败"
        errorMap[ERROR_USER_TOKEN_EXPIRED] = "token已失效"
        errorMap[ERROR_USER_USER_NOT_EXIST] = "用户不存在"
        errorMap[ERROR_USER_USERNAME_OR_PWD_EMPTY] = "用户名或密码为空"
        errorMap[ERROR_USER_WRONG_PASSWORD] = "密码错误"
        errorMap[ERROR_USER_NOT_LOGIN_PERMISSION] = "帐号被冻结"

        errorMap[ERROR_GOODS_AT_LEAST_ONE_PIC] = "至少上传一张图片"
        errorMap[ERROR_GOODS_NO_MORE_RECORD] = "没有更多数据了~"
        errorMap[ERROR_GOODS_NO_PUBLISH_PERMISSION] = "限制发布"

        errorMap[ERROR_ORDER_UNKNOWN] = "未知错误"
        errorMap[ERROR_ORDER_NOT_EXIST] = "订单不存在"
        errorMap[ERROR_ORDER_NOT_ORDERS] = "没有任何订单"
        errorMap[ERROR_ORDER_GOODS_NOT_EXIST] = "宝贝已经不存在"
        errorMap[ERROR_ORDER_NO_BUY_PERMISSION] = "购买限制"

        errorMap[ERROR_RECORD_NOT_ANY_BOUGHT] = "无买到记录"
        errorMap[ERROR_RECORD_NOT_ANY_COLLECTION] = "无收藏记录"
        errorMap[ERROR_RECORD_NOT_ANY_SOLD] = "无卖出记录"
        errorMap[ERROR_RECORD_NOT_RECORD] = "没有相关记录"

        errorMap[ERROR_RES_UPLOAD_FAIL] = "文件上传失败"
        errorMap[ERROR_COMMENT_COMMENT_FAIL] = "评论失败"
        errorMap[ERROR_COMMENT_NO_COMMENT] = "暂无评论~"
        errorMap[ERROR_COMMENT_DELETE_FAIL] = "删除失败"
        errorMap[ERROR_COMMENT_NO_PERMISSION] = "限制评论"

    }

    fun getMsg(state: String): String{
        return msgMap[state] ?: ""
    }

    fun getEorrorStr(error: String): String{
        return errorMap[error] ?: "null"
    }
}



object NeteaseApi{
    const val UIL_VERIFY_CODE = "https://api.netease.im/sms/sendcode.action"
    const val TEMPLATE_ID = "14797026"
    const val CODE_LEN = "6"
}

object JuHeApi{
    const val URL_SMS_CDOE = "http://v.juhe.cn/sms/send"
    const val TEMPLATE_ID = "155345"
}
